home *** CD-ROM | disk | FTP | other *** search
- Path: news.win.tue.nl!not-for-mail
- From: joepdv@wsooti21.win.tue.nl (Joep de Vocht)
- Newsgroups: comp.lang.c++
- Subject: HELP: what goes wrong here?
- Date: 20 Apr 1996 15:43:09 +0200
- Organization: Eindhoven University of Technology, The Netherlands
- Message-ID: <4lapld$1q4@wsooti21.win.tue.nl>
- NNTP-Posting-Host: wsooti21.win.tue.nl
- Summary: HELP: I can't get this simple program to compile
- Keywords: HELP
-
- This question is probably very easy to solve.
- However, the program given below won't compile and
- I can't figure out why.
- Maybe you can help a C++ novice.
-
- The two compiler errors given by the turbo c++ compiler are
- included in the code. If you have any other remarks about
- the code (weird constructions or anything) please state them.
-
- Greetings,
-
- Joep.
-
- ------------ main program ------------
- #include "x.h"
- #include "base.h"
- #include "derived.h"
-
- int main()
- {
- derived d() ;
- d.execute() ;
- return 0 ;
- }
-
- ------------ X.h ---------------------
- class X
- {
- private:
- int n ;
- public:
- X(int i) {n=i ;}
- void do_someting() ;
- } ;
-
- ------------ X.cpp -------------------
- #include "x.h"
-
- void X::do_someting() {n++ ;}
-
- ------------ base.h ------------------
- class base
- {
- protected:
- static X x ; COMPILER ERROR: ", exspected"
- public:
- base() ;
- virtual void execute() =0 ;
- } ;
-
- ------------ base.cpp ----------------
- #include "base.h"
-
- base::base() { x(10) ;} ; COMPILER ERROR: "call of non-function"
-
- ------------ derived.h ---------------
- class derived: public base
- {
- public:
- derived() ;
- void execute(int) ;
- } ;
-
- ------------ derived.cpp -------------
- #include "derived.h"
-
- derived::derived():base() ;
- void derived::execute() { x.do_something() ;}
-
-
-
-
-